<?php

use yii\helpers\Html;
use yii\widgets\DetailView;

/* @var $this yii\web\View */
/* @var $model common\models\Config */

$this->title = $model->title;
$this->params['breadcrumbs'][] = ['label' => '基础配置列表', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
\yii\web\YiiAsset::register($this);
?>
<div class="config-view">

    <div class="box box-primary">
        <div class="box-header with-border">
          <h3 class="box-title">操作</h3>
        </div>
        <div class="box-body">
            <p>
                <?= Html::a('编辑', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
                <?= Html::a('删除', ['delete', 'id' => $model->id], [
                    'class' => 'btn btn-danger',
                    'data' => [
                        'confirm' => 'Are you sure you want to delete this item?',
                        'method' => 'post',
                    ],
                ]) ?>

                <?php if($model->type == 'img'){ ?>
                    <?= Html::a('图片上传', ['upload', 'id' => $model->id], ['class' => 'btn btn-info']) ?>
                <?php }?>
            </p>
        </div>
    </div>
    <div class="row">
        <div class="col-md-6">
            <div class="box box-solid box-primary">
                <div class="box-header">
                  <h3 class="box-title">详情</h3>
                </div>
                <div class="box-body">
                    <?= DetailView::widget([
                        'model' => $model,
                        'attributes' => [
                            'id',
                            [
                                'format' => 'raw',
                                'attribute' => 'cid',
                                'value' => function($model) {
                                    if($model->cid == 1){
                                        return '基本设置';
                                    }elseif($model->cid == 2){
                                        return 'seo';
                                    }else{
                                        return '';
                                    }
                                },
                            ],
                            [
                                'format' => 'raw',
                                'attribute' => 'type',
                                'value' => function($model) {
                                    if($model->type == 'img'){
                                        return '图片';
                                    }else{
                                        return '文本';
                                    }
                                },
                            ],
                            'key',
                            'title',
                            'value',
                            'remark',
                            'sort',
                            [
                                'format' => 'raw',
                                'attribute' => 'create_time',
                                'value' => function($model) {
                                    return date('Y-m-d H:i', $model->create_time);
                                },
                            ],
                            [
                                'format' => 'raw',
                                'attribute' => 'update_time',
                                'value' => function($model) {
                                    return date('Y-m-d H:i', $model->update_time);
                                },
                            ],
                        ],
                    ]) ?>
                </div>
            </div>
        </div>
        <?php if($model->type == 'img'){ ?>
        <div class="col-md-6">
            <div class="box box-solid box-primary" style="background: rgba(255,255,255,.2)">
                <div class="box-header">
                  <h3 class="box-title">图片展示</h3>
                </div>
                <div class="box-body">
                   <img src="<?=$model->value?>" style="border:1px solid #333;width: 100%" >
                </div>
            </div>
        </div>
        <?php }?>
        <div class="clearfix"></div>
    </div>
    
    

</div>
